<?php
require_once ('./config.php');

$obj = array(
    'code' => 0,
    'msg' => '登录失败'
);
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
if(!isset($username) || !isset($password)){
    $obj['msg'] = '缺少必要参数';
    die(json_encode($obj));
};

$chaxun = "SELECT * FROM list1 WHERE username = '$username'";
$result = mysqli_query($conn,$chaxun);
$data = mysqli_fetch_assoc($result);

if($data){
    if($data['password'] == $password){
        $obj['code'] = 1 ;
        $obj['msg'] = '登录成功';
    }else{
        $obj['msg'] = '用户名或密码错误';
    }
}else{
    $obj['msg'] = '用户名或密码错误';
};
echo json_encode($obj);